﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ecreate.Business;
using Ecreate.Model;
namespace Ecreate.Web.systemanage.productclass
{
    public partial class treeview : System.Web.UI.Page
    {
        public string str_xml = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = this.Request.QueryString["type"];
            if (!String.IsNullOrEmpty(type))
            {
                string id = this.Request.QueryString["classid"];
                ProductClass p = new ProductClass();
                p.Classid = id;

                ProductService productService = new ProductService();
                Product product = new Product();
                product.Classid = p.Classid;
                ArrayList list = productService.getProductByClassID(product);
                if (list.Count > 0)
                {

                    Response.Write("<script type=\"text/javascript\" language=\"javascript\">        alert('该产品类别下包含有产品,不允许删除!');　; </script>");


                }
                else
                {

                    ProductClassService service = new ProductClassService();
                    service.Delete(p);
                    RefreshTree();
                }
                Response.Write("<script type=\"text/javascript\" language=\"javascript\">          window.parent.frames[\"client\"].location=\"/systemanage/client.aspx\"　　; </script>");

            }
            if (!IsPostBack)
            {
                RefreshTree();
            }
        }
        private void RefreshTree()
        {
            ProductClassService tservice = new ProductClassService();
            this.str_xml = tservice.getXmlString();
        }
    }
}
